<script setup>
import { ref } from 'vue';
let po = ref("")
let jo = ref("")
let s = ref('');
let yy = ref('');
let uu = /\D/
function fn() {
    if (po.value == '') {
        alert('不能为空')
    } else if (uu.test(po.value)) {
        alert("输入必须是数字")
    } else {
        s.value = (po.value * 4 - jo.value) / 2 //鸡
        yy.value = po.value - s.value //兔
        // 下面是弹出答案
        return alert("兔有" + s.value + "鸡有" + yy.value)
    }
}
</script>

<template>
    <div>
        <div class="ww">
            <div class="zhu">
                <label for="tou">一共有多少个头:</label>
                <input type="text" name="tou" id="tou" v-model="po" placeholder="请输入有多少个头">
                <label for="jiao">多少只脚:</label>
                <input type="text" name="jiao" id="jiao" v-model="jo" placeholder="请输入有多少只脚">
                <button @click="fn">确认</button>
            </div>
        </div>
    </div>
</template>

<style scoped>
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-size: 12px;

}

.ww {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 500px;
}

.zhu {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.zhu input {
    width: 130px;
    padding: 5px;
    border: 1px #ccc solid;
    outline: none;
    border-radius: 20px;
}

.zhu button {
    background-color: rgba(0, 0, 0, 0.8);
    border: none;
    width: 50px;
    height: 30px;
    border-radius: 20px;
    margin: 0 auto;
    color: rgb(255, 255, 255);
}

.zuo {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.wb {
    padding-right: 100px;

}

.jx span {
    color: red;
}

.wenben {
    color: red;
    font-size: 20px;
    font-weight: bold;
}
</style>
